<!DOCTYPE html>
<html  class="iframe-h">
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
  		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>回调管理中心</title>
		<link rel="stylesheet" type="text/css" href="../../static/admin/layui/css/layui.css"/>
		<link rel="stylesheet" type="text/css" href="../../static/admin/css/admin.css"/>
	</head>
	<body  class="iframe-h">
	<div class="wrap-container email-wrap clearfix">
		<div class="demoTable">
			url：
			<div class="layui-inline">
				<input class="layui-input" name="url" type="text" id="search-url" autocomplete="off" style="width: 200px;">
			</div>
			&nbsp;&nbsp;&nbsp;&nbsp;
			taskId：
			<div class="layui-inline">
				<input class="layui-input" name="url" type="text" id="search-taskId" autocomplete="off" style="width: 310px;">
			</div>
			&nbsp;&nbsp;&nbsp;&nbsp;
			创建时间：
			<div class="layui-inline">
				<input class="layui-input" name="createTime" type="text" id="search-createTime" style="width: 300px;">
			</div>
			<button class="layui-btn" data-type="reload">搜索</button>
            <button class="layui-btn" id="refresh-btn" style="float: right">刷新页面</button>
		</div>
		<table class="layui-hide" id="LAY_table_fulltask" lay-filter="demo"></table>
		<script type="text/html" id="barDemo">
			{{#  if(!d.success){ }}
				<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="resend">重新发起</a>
			{{#  } }}
		</script>
	</div>
	<script src="../../static/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<script>
        layui.use(['table', 'laydate'], function() {
            var table = layui.table;
            var laydate = layui.laydate;
            table.render({
                elem: '#LAY_table_fulltask'
                ,url:'/manager/getFullTask'
				,method:'post'
                ,cols: [[
                    {field:'url',title: 'url'}
                    ,{field:'taskId',title: 'taskId', width: 90}
                    ,{field:'requestMethod',title: '请求方式', width: 90}
                    ,{field:'requestParam', title: '请求参数'
                        ,templet: function(item){
                            return JSON.stringify(item.requestParam)
                        }
                    }
                    ,{field:'sourceIp',title: '请求IP', width: 120}
                    ,{field:'success',title: '是否成功', width: 90
                        ,templet: function(item){
                            return item.success ? '是':'否'
                        }
                    }
                    ,{field:'callCount',title: '重试次数', width: 90}
                    ,{field:'limitCallCount',title: '限制次数', width: 90}
                    ,{field:'createDate',title: '创建时间', width: 170}
                    ,{title: '操作', toolbar: '#barDemo', width: 100}
                ]]
				,id: 'LAY_table_fulltask'
                ,page: true
                ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.count, //解析数据长度
                        "data": res.data.resultList //解析数据列表
                    };
                }
            });
            var $ = layui.$, active = {
                reload: function(){
                    var url = $('#search-url');
                    var taskId = $('#search-taskId');
					var createTime = $('#search-createTime');
                    //执行重载
                    table.reload('LAY_table_fulltask', {
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                        ,where: {
                            url: url.val()
							,taskId: taskId.val()
							,createTime: createTime.val()
                        }
                    });
                }
            };
            $('.demoTable .layui-btn').on('click', function(){
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });

            $('#refresh-btn').on('click', function () {
                var url = $('#search-url');
				var taskId = $('#search-taskId');
                var createTime = $('#search-createTime');
                url.val('');
				taskId.val('');
				createTime.val('');
                table.reload('LAY_table_fulltask', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        url: url.val()
						,taskId: taskId.val()
						,createTime: createTime.val()
                    }
                });
            })

            //监听工具条
            table.on('tool(demo)', function(obj){
                var data = obj.data;
                if(obj.event === 'resend') {
                    var url = $('#search-url');
					var taskId = $('#search-taskId');
					var createTime = $('#search-createTime');
                    $.post("/manager/retry",
					{
						taskId: data.taskId
					},
					function(data){
						layer.alert(data);
                        table.reload('LAY_table_fulltask', {
                                where: {
                                    url: url.val()
									,taskId: taskId.val()
									,createTime: createTime.val()
                                }
                            }
						);
					});
                }
            });

            //日期时间选择框
			//日期时间范围
			laydate.render({
				elem: '#search-createTime'
				,type: 'datetime'
				,range: true
				,done: function(value, date, endDate){
					$('#search-createTime').val(value);
				}
			});
		});
	</script>
</body>
</html>